﻿#region using

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

#endregion

namespace JupiterLibrary
{
    public class Render
    {
        internal Render()
        {

        }

        public void FilledRectangle(Rectangle rectangle, Color color)
        {
            Vector3 a, b, c, d;

            a = new Vector3(rectangle.X, rectangle.Top,0);
            b = new Vector3(rectangle.X, rectangle.Bottom,0);
            c = new Vector3(rectangle.Right, rectangle.Bottom,0);
            d = new Vector3(rectangle.Right, rectangle.Top,0);

            VertexPositionColor[] vertices={ 
                new VertexPositionColor(b,color),
                new VertexPositionColor(a,color),
                new VertexPositionColor(c,color),
                new VertexPositionColor(d,color)
            };

            BasicEffect basicEffect = Jupiter.Video.BasicEffect;

            basicEffect.VertexColorEnabled = true;

            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                Jupiter.Video.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip,vertices,0,2);
            }
        }

        public void Rectangle(Rectangle rectangle, Color color)
        {
            FilledRectangle(new Rectangle(rectangle.X, rectangle.Y,rectangle.Width,1), color);
            FilledRectangle(new Rectangle(rectangle.X, rectangle.Bottom-1, rectangle.Width, 1), color);
            FilledRectangle(new Rectangle(rectangle.X, rectangle.Y, 1,rectangle.Height), color);
            FilledRectangle(new Rectangle(rectangle.Right - 1, rectangle.Y, 1, rectangle.Height), color);
        }
    }
}
